<?php

class module_permission extends a_admin_controller{
    protected $srv;
    protected $selected_group_id;
    protected $modules;
    public function  __construct($post_handling_enabled = FALSE) {
        parent::__construct($post_handling_enabled);
        include_once get_module_path("acl", module_u_acl::ACL_PERMISSION_DRIVERS_FOLDER)."driver_module_permission".EXT;
        $this->srv = new service_l_acl();        
        $this->selected_group_id = $this->input->post("select_group");
        $this->modules  = driver_module_permission::get_modules($this->selected_group_id ? $this->selected_group_id : NULL);
    }

    public function index(){
        
    }

    public function toggle_module_permission(){
        $module_name = $this->input->post("module_name");
        $group_id    = $this->input->post("group_id");
        $flag        = $this->input->post("flag");
        if($module_name && $group_id){
            $falg = $flag=="1" ? TRUE:FALSE;
            driver_module_permission::enlable_diable_permission($module_name, $group_id, $flag);
            return "ok";
        }else  return "nok";
    }
    public function  batch_assign() {        
        $this->assign("modules", $this->modules);
        $this->assign("selected_group_id",$this->selected_group_id);
        $this->assign("groups",  $this->srv->list_all_groups(TRUE));
    }


}
?>
